package cn.edu.cug.cs.gtl.renders.openinventor.paths;

import cn.edu.cug.cs.gtl.apis.render.paths.GeneralPath;
import cn.edu.cug.cs.gtl.apis.render.paths.NodeKitPath;
import cn.edu.cug.cs.gtl.apis.render.paths.Path;
import com.openinventor.inventor.SoPath;

import java.util.HashMap;

public class PathImpl implements Path {
    protected SoPath nativeObject=null;
    public PathImpl() {
        this.nativeObject = new SoPath();
    }

    public PathImpl(SoPath p) {
        this.nativeObject = p;
    }


    @Override
    public Object getNativeObject() {
        return this.nativeObject;
    }

    @Override
    public boolean attach(Object nativeObject) {
        if(nativeObject instanceof SoPath) {
            this.nativeObject = (SoPath) nativeObject;
            return true;
        }
        else
            return  false;
    }

    @Override
    public Object detach() {
        Object object = this.nativeObject;
        this.nativeObject=null;
        return object;
    }

    @Override
    public GeneralPath full() {
        return new GeneralPathImpl(this.nativeObject.full);
    }

    @Override
    public NodeKitPath nodeKit() {
        return new NodeKitPathImpl(this.nativeObject.nodekit);
    }

    @Override
    public GeneralPath regular() {
        return new GeneralPathImpl(this.nativeObject.full);
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof SoPath){
            return this.nativeObject.equals(obj);
        }
        if(obj instanceof Path){
            return this.nativeObject.equals((SoPath) ((Path) obj).getNativeObject());
        }
        return super.equals(obj);
    }
}
